import fs from 'node:fs'
import download from 'download-git-repo'
import ora from 'ora'
const spinner = ora('下载中...')
//验证路径
export const checkPath = path => {
  return fs.existsSync(path)
}

//下载
export const downloadTemp = (branch, project) => {
  spinner.start()
  return new Promise((resolve, reject) => {
    download(
      `direct:https://gitee.com/chinafaker/vue-template.git#${branch}`,
      project,
      { clone: true },
      function (err) {
        if (err) {
          reject(err)
          console.log(err)
        }
        resolve()
        spinner.succeed('下载完成')
      }
    )
  })
}
/* npm link
用于生成软连接挂载到全局，便可以全局执行vue-cli 这个命令，配置完成之后 需要执行
 */
